//1.引入Vuex Api
import { createStore } from 'vuex'
import user from './modules/user'

//2.创建一个Vuex实例化对象
const store = createStore({
  modules: {
    user
  },
  state: {
    routeLoaded: false, // 菜单和路由加载
    firstRoute: null, // 第一个路由，用于进入主页时redirect
    menuTree: null // 菜单树
  },
  mutations: {
    setRouteLoaded(state, loaded) {
      state.routeLoaded = loaded
    },
    setFirstRoute(state, route) {
      state.firstRoute = route
    },
    setMenuTree(state, data) {
      state.menuTree = data
    }
  }
})
//对外暴露Vuex实例化对象
export default store
